package cn.tedu._07article.base.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.lang.ref.PhantomReference;
@AllArgsConstructor
@Getter
@Setter
@NoArgsConstructor
public class JsonResult {
    private int status;
    private String message;
    private Object data;

    JsonResult(StatusCode code, Object data)
    {
        this.status=code.getStatus();
        this.message= code.getMessage();
        this.data = data;
    }
    public JsonResult(StatusCode statusCode) {
        this.status = statusCode.getStatus();
        this.message = statusCode.getMessage();
    }

    public static JsonResult ok(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS, data);
    }

    public static JsonResult ok(){
        return new JsonResult(StatusCode.OPERATION_SUCCESS);
    }
}
